// bzoj1116
// 题意：
//
// 题解：
//
// run: $exec < input
#include <cstdio>
#include <vector>
#include <utility>

int const maxn = 100007;
int father[maxn];
int count[maxn];
int count_node[maxn];
int n, m;
std::vector<std::pair<int, int> > edges;

int get_father(int x)
{
	return (x == father[x] ? x : (father[x] = get_father(father[x])));
}

void set_union(int x, int y)
{
	int tx = get_father(x);
	int ty = get_father(y);
	if (tx != ty) father[tx] = ty;
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) father[i] = i;
	for (int i = 0, x, y; i < m; i++) {
		scanf("%d%d", &x, &y);
		edges.push_back(std::make_pair(x, y));
		set_union(x, y);
	}
	for (int i = 1; i <= n; i++) father[i] = get_father(father[i]);
	for (int i = 0; i < (int)edges.size(); i++)
		count[father[edges[i].first]]++;
	for (int i = 1; i <= n; i++)
		count_node[father[i]]++;
	bool ok = true;
	for (int i = 1; i <= n; i++)
		if (count_node[father[i]] - 1 >= count[father[i]]) {
			ok = false;
			break;
		}
	if (ok) printf("TAK\n");
	else printf("NIE\n");
}

